$(function () {
    cid = '';
    assortid = '';
    goods_type = 1;
    /**
     * liebiao
     */
    HOME.ajaxFn({
        url: HOME.baseUrl.goodslist,
        type: 'GET',
        dataType: 'json',
        data: {
            page_size: 9,
            page: 1,
            goods_type: goods_type,
            c_id: cid,
            assort: assortid
        }
    }, function (res) {
        $('#listdt').html(template('listdtTpl', {'res': res}));

        $("#pager").zPager({
            totalData: parseInt(res.total),  //总条数
            pageData: 9,  //没页显示多少个
            htmlBox: $('#wraper'),
            btnShow: true,
            ajaxSetData: false
        });
    });

    /**
     * 分类导航
     */
    HOME.ajaxFn({
        url: HOME.baseUrl.classify,
        type: 'GET',
        dataType: 'json',
        data: {}
    }, function (res) {
        $('#classify').html(template('classifyTpl', {'res': res}));
        $('#classify li').eq(HOME.getQueryVariable('index_type')).addClass('cur_li')
    });


    $('body').on('click', '.rh_url_l li', function () {
        var _this = $(this);
        var parentClass = $(this).parent('.rh_url_l').hasClass('rh_url_l_cur');
        var dataId = $(this).attr('data_id');
        if (parentClass) {
            cid = dataId
        } else {
            assortid = dataId
        }
        HOME.ajaxFn({
            url: HOME.baseUrl.goodslist,
            type: 'GET',
            dataType: 'json',
            data: {
                page_size: 9,
                page: 1,
                goods_type: goods_type,
                c_id: cid,
                assort: assortid
            }
        }, function (res) {
            _this.addClass('cur_li').siblings().removeClass('cur_li')
            $('#listdt').html(template('listdtTpl', {'res': res}));
            $("#pager").zPager({
                totalData: parseInt(res.total),  //总条数
                pageData: 9,  //没页显示多少个
                htmlBox: $('#wraper'),
                btnShow: true,
                ajaxSetData: false
            });
        })
    })

});
function currentPage(currentPage) {
    /*
      触发页码数位置： Page/js/jquery.z-pager.js 64行
    */
    console.log("当前页码数：" + currentPage);
    HOME.ajaxFn({
        url: HOME.baseUrl.goodslist,
        type: 'GET',
        dataType: 'json',
        data: {
            page_size: 9,
            page: currentPage,
            goods_type: goods_type,
            c_id: cid,
            assort: assortid
        }
    }, function (res) {
        $('#listdt').html(template('listdtTpl', {'res': res}));
    });
}